import React, { Component } from "react";

class App extends Component {
  state = {
    textValue: 123,
  };

  handleChange = (e) => {
    this.setState({
      textValue: e.target.value,
    });
  };

  render() {
    return (
      <>
        {/* 输入框里面绑定的值，永远不要变成null或者undefined */}
        <h3>受控输入空值</h3>
        <input
          type="text"
          value={this.state.textValue}
          onChange={this.handleChange}
        />
      </>
    );
  }

  componentDidMount() {
    setTimeout(() => {
      this.setState({
        textValue: null,
      });
    }, 3000);
  }
}

export default App;
